#!/bin/sh

# 获取版本号
config=`sed -n '1p' config/index.ts |awk -F '= ' '{print $2}'`
version=${config:1:4}

path=$(cd `dirname $0`; pwd)
folder=h5-unimarketing

cd .nuxt/dist/client
tar -zcf $path/version/$version.cdn.tar.gz ./*

cd ../../..
tar -zcf $path/version/$version.source.tar.gz .nuxt assets server static package.json tsconfig.json nodemon.json app.html ecosystem.config.js node_modules config nuxt.config.ts

# scp ./version/$version.cdn.tar.gz tuijian@sd005:/data/www/protal/h5/unimarketing
# ssh tuijian@sd005 "cd /data/www/protal/h5/unimarketing && sh unzip.sh $version"
# echo 'cdn 更新完成'

# scp ./version/$version.source.tar.gz tuijian@sd029:/home/tuijian/app/$folder
# ssh tuijian@sd029 "cd /home/tuijian/app/$folder && sudo sh update.sh $version"
# echo 'sd029 更新完成'

scp ./version/$version.source.tar.gz tuijian@sd013:/home/tuijian/app/$folder
ssh tuijian@sd013 "cd /home/tuijian/app/$folder && sudo sh update.sh $version"

echo 'sd013 更新完成'
